I'm trying to practice at getting better at Python, and even though you are coding in Java, this was still very helpful! I was able to translate it over to Python. Thank you for the explanations and heads up on the type of questions!
2nd one why not use a hash map to clamp each value to its frequency, then iterate through hash map to find the largest one? O(n) runtime instead of n^2 I agree with others that #3 could make use of memoization but if the point is to use recursion it is the textbook case of recursion
That's the optimal solution for that problem. As for the n-th Fibonacci problem, she could've used Dynamic Programming. You could've just created an array and then recursively call Fibonacci numbers and then stored them. When you need to find the n-th Fibonacci number, you could've just called from the array. That's technically recursion, because we're still using recursion to generate and therefore store. The complexity of that would've been pseudo-polynomial time, meaning O(n) and space is O(n).
I was just about to comment this. Just check if the hashmap has the array value as a key, if it doesnt: make it a key with the value of 1, otherwise increment the value of that key in the hashmap by one. After that its a basic traversal of the hashmap to check for the highest value's key.
I'm trying to practice at getting better at Python, and even though you are coding in Java, this was still very helpful! I was able to translate it over to Python. Thank you for the explanations and heads up on the type of questions!
2nd one why not use a hash map to clamp each value to its frequency, then iterate through hash map to find the largest one?
O(n) runtime instead of n^2
I agree with others that #3 could make use of memoization but if the point is to use recursion it is the textbook case of recursion
That's the optimal solution for that problem. As for the n-th Fibonacci problem, she could've used Dynamic Programming. You could've just created an array and then recursively call Fibonacci numbers and then stored them. When you need to find the n-th Fibonacci number, you could've just called from the array. That's technically recursion, because we're still using recursion to generate and therefore store. The complexity of that would've been pseudo-polynomial time, meaning O(n) and space is O(n).
I was just about to comment this. Just check if the hashmap has the array value as a key, if it doesnt: make it a key with the value of 1, otherwise increment the value of that key in the hashmap by one. After that its a basic traversal of the hashmap to check for the highest value's key.
This was awesome, good explanations. Looking forward to more content!
Thank you, I am glad you liked it! I will have 2 more problem explanations coming out later today :)
This is what I have been looking for!!!
Please discuss Graphs. I have a really hard time solving graph problems.
Sure! I will add that to my list of videos to make :)
Amazing job! Thank you, once more. It seems i'm not so far off!!! woo-hoo :-)
You are very helpful to me 😊
These questions are too simple to be asked.
I interned at 3 large, well known companies and one seed-stage start up. During each interview process, I was asked at least one of these questions.
@@givemeabreak2469 ahan, thanks for sharing that info...